package com.cll.learn.queue;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 描述信息:
 *
 * @author CLL
 * @version 1.0
 * @date 2021/5/15 20:21
 */
public class AddThread implements Runnable {

    private static AtomicInteger atomicInteger = new AtomicInteger(0);

    private final MyBlockingQueue myBlockingQueue;

    public AddThread(MyBlockingQueue myBlockingQueue) {
        this.myBlockingQueue = myBlockingQueue;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(100);
                final int i = atomicInteger.incrementAndGet();
                myBlockingQueue.add(i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
